using System;
using System.Text;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using iBeauty.BusinessObjects;

namespace iBeauty.DAL
{
	public class ShopDAO
	{
		public ShopDAO()
		{
			DbProviderHelper.GetConnection();
		}
		public List<Shop> GetShops()
		{
			try
			{
				List<Shop> lstShops = new List<Shop>();
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("SELECT [ID],[CreateDate],[ModifiedDate],[TimeStamp],[ShopCode],[ShopName],[ShopType],[Address],[Email],[Phone],[Fax],[OpenTime],[CloseTime],[AccountId],[Note] FROM [Shop]",CommandType.Text);
				DbDataReader oDbDataReader = DbProviderHelper.ExecuteReader(oDbCommand);
				while (oDbDataReader.Read())
				{
					Shop oShop = new Shop();
					oShop.ID = Convert.ToString(oDbDataReader["ID"]);

					if(oDbDataReader["CreateDate"] != DBNull.Value)
						oShop.CreateDate = Convert.ToDateTime(oDbDataReader["CreateDate"]);

					if(oDbDataReader["ModifiedDate"] != DBNull.Value)
						oShop.ModifiedDate = Convert.ToDateTime(oDbDataReader["ModifiedDate"]);

					if(oDbDataReader["TimeStamp"] != DBNull.Value)
						oShop.TimeStamp = Convert.ToDateTime(oDbDataReader["TimeStamp"]);

					if(oDbDataReader["ShopCode"] != DBNull.Value)
						oShop.ShopCode = Convert.ToString(oDbDataReader["ShopCode"]);

					if(oDbDataReader["ShopName"] != DBNull.Value)
						oShop.ShopName = Convert.ToString(oDbDataReader["ShopName"]);

					if(oDbDataReader["ShopType"] != DBNull.Value)
						oShop.ShopType = Convert.ToInt32(oDbDataReader["ShopType"]);

					if(oDbDataReader["Address"] != DBNull.Value)
						oShop.Address = Convert.ToString(oDbDataReader["Address"]);

					if(oDbDataReader["Email"] != DBNull.Value)
						oShop.Email = Convert.ToString(oDbDataReader["Email"]);

					if(oDbDataReader["Phone"] != DBNull.Value)
						oShop.Phone = Convert.ToString(oDbDataReader["Phone"]);

					if(oDbDataReader["Fax"] != DBNull.Value)
						oShop.Fax = Convert.ToString(oDbDataReader["Fax"]);

					if(oDbDataReader["OpenTime"] != DBNull.Value)
						oShop.OpenTime = Convert.ToDateTime(oDbDataReader["OpenTime"]);

					if(oDbDataReader["CloseTime"] != DBNull.Value)
						oShop.CloseTime = Convert.ToDateTime(oDbDataReader["CloseTime"]);

					if(oDbDataReader["AccountId"] != DBNull.Value)
						oShop.AccountId = Convert.ToInt32(oDbDataReader["AccountId"]);

					if(oDbDataReader["Note"] != DBNull.Value)
						oShop.Note = Convert.ToString(oDbDataReader["Note"]);
					lstShops.Add(oShop);
				}
				oDbDataReader.Close();
				return lstShops;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public Shop GetShop(string ID)
		{
			try
			{
				Shop oShop = new Shop();
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("SELECT [ID],[CreateDate],[ModifiedDate],[TimeStamp],[ShopCode],[ShopName],[ShopType],[Address],[Email],[Phone],[Fax],[OpenTime],[CloseTime],[AccountId],[Note] FROM [Shop] WHERE [ID]=@ID",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ID",DbType.String,ID));
				DbDataReader oDbDataReader = DbProviderHelper.ExecuteReader(oDbCommand);
				while (oDbDataReader.Read())
				{
					oShop.ID = Convert.ToString(oDbDataReader["ID"]);

					if(oDbDataReader["CreateDate"] != DBNull.Value)
						oShop.CreateDate = Convert.ToDateTime(oDbDataReader["CreateDate"]);

					if(oDbDataReader["ModifiedDate"] != DBNull.Value)
						oShop.ModifiedDate = Convert.ToDateTime(oDbDataReader["ModifiedDate"]);

					if(oDbDataReader["TimeStamp"] != DBNull.Value)
						oShop.TimeStamp = Convert.ToDateTime(oDbDataReader["TimeStamp"]);

					if(oDbDataReader["ShopCode"] != DBNull.Value)
						oShop.ShopCode = Convert.ToString(oDbDataReader["ShopCode"]);

					if(oDbDataReader["ShopName"] != DBNull.Value)
						oShop.ShopName = Convert.ToString(oDbDataReader["ShopName"]);

					if(oDbDataReader["ShopType"] != DBNull.Value)
						oShop.ShopType = Convert.ToInt32(oDbDataReader["ShopType"]);

					if(oDbDataReader["Address"] != DBNull.Value)
						oShop.Address = Convert.ToString(oDbDataReader["Address"]);

					if(oDbDataReader["Email"] != DBNull.Value)
						oShop.Email = Convert.ToString(oDbDataReader["Email"]);

					if(oDbDataReader["Phone"] != DBNull.Value)
						oShop.Phone = Convert.ToString(oDbDataReader["Phone"]);

					if(oDbDataReader["Fax"] != DBNull.Value)
						oShop.Fax = Convert.ToString(oDbDataReader["Fax"]);

					if(oDbDataReader["OpenTime"] != DBNull.Value)
						oShop.OpenTime = Convert.ToDateTime(oDbDataReader["OpenTime"]);

					if(oDbDataReader["CloseTime"] != DBNull.Value)
						oShop.CloseTime = Convert.ToDateTime(oDbDataReader["CloseTime"]);

					if(oDbDataReader["AccountId"] != DBNull.Value)
						oShop.AccountId = Convert.ToInt32(oDbDataReader["AccountId"]);

					if(oDbDataReader["Note"] != DBNull.Value)
						oShop.Note = Convert.ToString(oDbDataReader["Note"]);
				}
				oDbDataReader.Close();
				return oShop;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int AddShop(string ID,DateTime?CreateDate,DateTime?ModifiedDate,DateTime?TimeStamp,string ShopCode,string ShopName,int?ShopType,string Address,string Email,string Phone,string Fax,DateTime?OpenTime,DateTime?CloseTime,int?AccountId,string Note)
		{
			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("INSERT INTO [Shop]([CreateDate],[ModifiedDate],[TimeStamp],[ShopCode],[ShopName],[ShopType],[Address],[Email],[Phone],[Fax],[OpenTime],[CloseTime],[AccountId],[Note])VALUES(@CreateDate,@ModifiedDate,@TimeStamp,@ShopCode,@ShopName,@ShopType,@Address,@Email,@Phone,@Fax,@OpenTime,@CloseTime,@AccountId,@Note)",CommandType.Text);
				if (CreateDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,CreateDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,DBNull.Value));
				if (ModifiedDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,ModifiedDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,DBNull.Value));
				if (TimeStamp.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,TimeStamp));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,DBNull.Value));
				if (ShopCode!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopCode",DbType.String,ShopCode));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopCode",DbType.String,DBNull.Value));
				if (ShopName!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopName",DbType.String,ShopName));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopName",DbType.String,DBNull.Value));
				if (ShopType.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopType",DbType.Int32,ShopType));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopType",DbType.Int32,DBNull.Value));
				if (Address!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Address",DbType.String,Address));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Address",DbType.String,DBNull.Value));
				if (Email!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Email",DbType.String,Email));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Email",DbType.String,DBNull.Value));
				if (Phone!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Phone",DbType.String,Phone));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Phone",DbType.String,DBNull.Value));
				if (Fax!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Fax",DbType.String,Fax));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Fax",DbType.String,DBNull.Value));
				if (OpenTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@OpenTime",DbType.DateTime,OpenTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@OpenTime",DbType.DateTime,DBNull.Value));
				if (CloseTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CloseTime",DbType.DateTime,CloseTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CloseTime",DbType.DateTime,DBNull.Value));
				if (AccountId.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,AccountId));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,DBNull.Value));
				if (Note!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,Note));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,DBNull.Value));

				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int AddShop(Shop oShop)
		{
			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("INSERT INTO [Shop]([CreateDate],[ModifiedDate],[TimeStamp],[ShopCode],[ShopName],[ShopType],[Address],[Email],[Phone],[Fax],[OpenTime],[CloseTime],[AccountId],[Note])VALUES(@CreateDate,@ModifiedDate,@TimeStamp,@ShopCode,@ShopName,@ShopType,@Address,@Email,@Phone,@Fax,@OpenTime,@CloseTime,@AccountId,@Note)",CommandType.Text);
				if (oShop.CreateDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,oShop.CreateDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,DBNull.Value));
				if (oShop.ModifiedDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,oShop.ModifiedDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,DBNull.Value));
				if (oShop.TimeStamp.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,oShop.TimeStamp));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,DBNull.Value));
				if (oShop.ShopCode!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopCode",DbType.String,oShop.ShopCode));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopCode",DbType.String,DBNull.Value));
				if (oShop.ShopName!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopName",DbType.String,oShop.ShopName));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopName",DbType.String,DBNull.Value));
				if (oShop.ShopType.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopType",DbType.Int32,oShop.ShopType));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopType",DbType.Int32,DBNull.Value));
				if (oShop.Address!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Address",DbType.String,oShop.Address));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Address",DbType.String,DBNull.Value));
				if (oShop.Email!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Email",DbType.String,oShop.Email));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Email",DbType.String,DBNull.Value));
				if (oShop.Phone!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Phone",DbType.String,oShop.Phone));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Phone",DbType.String,DBNull.Value));
				if (oShop.Fax!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Fax",DbType.String,oShop.Fax));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Fax",DbType.String,DBNull.Value));
				if (oShop.OpenTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@OpenTime",DbType.DateTime,oShop.OpenTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@OpenTime",DbType.DateTime,DBNull.Value));
				if (oShop.CloseTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CloseTime",DbType.DateTime,oShop.CloseTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CloseTime",DbType.DateTime,DBNull.Value));
				if (oShop.AccountId.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,oShop.AccountId));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,DBNull.Value));
				if (oShop.Note!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,oShop.Note));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,DBNull.Value));

				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int UpdateShop(string ID,DateTime?CreateDate,DateTime?ModifiedDate,DateTime?TimeStamp,string ShopCode,string ShopName,int?ShopType,string Address,string Email,string Phone,string Fax,DateTime?OpenTime,DateTime?CloseTime,int?AccountId,string Note)
		{

			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("UPDATE [Shop] SET [CreateDate]=@CreateDate,[ModifiedDate]=@ModifiedDate,[TimeStamp]=@TimeStamp,[ShopCode]=@ShopCode,[ShopName]=@ShopName,[ShopType]=@ShopType,[Address]=@Address,[Email]=@Email,[Phone]=@Phone,[Fax]=@Fax,[OpenTime]=@OpenTime,[CloseTime]=@CloseTime,[AccountId]=@AccountId,[Note]=@Note WHERE [ID]=@ID",CommandType.Text);
				if (CreateDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,CreateDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,DBNull.Value));
				if (ModifiedDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,ModifiedDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,DBNull.Value));
				if (TimeStamp.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,TimeStamp));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,DBNull.Value));
				if (ShopCode!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopCode",DbType.String,ShopCode));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopCode",DbType.String,DBNull.Value));
				if (ShopName!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopName",DbType.String,ShopName));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopName",DbType.String,DBNull.Value));
				if (ShopType.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopType",DbType.Int32,ShopType));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopType",DbType.Int32,DBNull.Value));
				if (Address!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Address",DbType.String,Address));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Address",DbType.String,DBNull.Value));
				if (Email!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Email",DbType.String,Email));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Email",DbType.String,DBNull.Value));
				if (Phone!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Phone",DbType.String,Phone));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Phone",DbType.String,DBNull.Value));
				if (Fax!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Fax",DbType.String,Fax));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Fax",DbType.String,DBNull.Value));
				if (OpenTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@OpenTime",DbType.DateTime,OpenTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@OpenTime",DbType.DateTime,DBNull.Value));
				if (CloseTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CloseTime",DbType.DateTime,CloseTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CloseTime",DbType.DateTime,DBNull.Value));
				if (AccountId.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,AccountId));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,DBNull.Value));
				if (Note!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,Note));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,DBNull.Value));
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ID",DbType.String,ID));
				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int UpdateShop(Shop oShop)
		{

			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("UPDATE [Shop] SET [CreateDate]=@CreateDate,[ModifiedDate]=@ModifiedDate,[TimeStamp]=@TimeStamp,[ShopCode]=@ShopCode,[ShopName]=@ShopName,[ShopType]=@ShopType,[Address]=@Address,[Email]=@Email,[Phone]=@Phone,[Fax]=@Fax,[OpenTime]=@OpenTime,[CloseTime]=@CloseTime,[AccountId]=@AccountId,[Note]=@Note WHERE [ID]=@ID",CommandType.Text);
				if (oShop.CreateDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,oShop.CreateDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,DBNull.Value));
				if (oShop.ModifiedDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,oShop.ModifiedDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,DBNull.Value));
				if (oShop.TimeStamp.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,oShop.TimeStamp));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,DBNull.Value));
				if (oShop.ShopCode!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopCode",DbType.String,oShop.ShopCode));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopCode",DbType.String,DBNull.Value));
				if (oShop.ShopName!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopName",DbType.String,oShop.ShopName));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopName",DbType.String,DBNull.Value));
				if (oShop.ShopType.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopType",DbType.Int32,oShop.ShopType));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopType",DbType.Int32,DBNull.Value));
				if (oShop.Address!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Address",DbType.String,oShop.Address));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Address",DbType.String,DBNull.Value));
				if (oShop.Email!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Email",DbType.String,oShop.Email));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Email",DbType.String,DBNull.Value));
				if (oShop.Phone!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Phone",DbType.String,oShop.Phone));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Phone",DbType.String,DBNull.Value));
				if (oShop.Fax!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Fax",DbType.String,oShop.Fax));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Fax",DbType.String,DBNull.Value));
				if (oShop.OpenTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@OpenTime",DbType.DateTime,oShop.OpenTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@OpenTime",DbType.DateTime,DBNull.Value));
				if (oShop.CloseTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CloseTime",DbType.DateTime,oShop.CloseTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CloseTime",DbType.DateTime,DBNull.Value));
				if (oShop.AccountId.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,oShop.AccountId));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,DBNull.Value));
				if (oShop.Note!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,oShop.Note));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,DBNull.Value));
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ID",DbType.String,oShop.ID));
				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int RemoveShop(Shop oShop)
		{

			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("DELETE FROM [Shop] WHERE [ID]=@ID",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ID",DbType.String,oShop.ID));
				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int RemoveShop(string ID)
		{

			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("DELETE FROM [Shop] WHERE [ID]=@ID",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ID",DbType.String,ID));
				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
	}
}
